﻿/*===============================================================================
	TASK 1c :                                           {Multidimentional Arrays}
	Write a program that fills and prints a matrix of size (n, n) as shown below:
    Example for n = 4
 
           7 11 14 16
           4  8 12 15 
           2  5  9 13
           1  3  6 10
================================================================================*/

using System;

class cMatrix
{
    static void Main()
    {
        int n = 5;
        int[,] matrix = new int[n, n];

        int counter = 1;
        int co = n * n;

        for (int i = n - 1; i >= 0; i--)
        {
            int row = i;
            for (int col = 0; col < n-i; col++)
            {
                matrix[row, col] = counter++;
                row++;
            }
        }

        for (int i = 0; i < n - 1; i ++)
        {
            int row = i;
            for (int col = n - 1; col >= n-1 - i; col--)
            {
                matrix[row, col] = co--;
                row--;
            }
        }

        for (int row = 0; row < n; row++)
        {
            for (int col = 0; col < n; col++)
            {
                Console.Write(matrix[row, col] + " ");
            }
            Console.WriteLine();
        }
    }
}

